package rgbos.forum.domain;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Searchable
public class Post  {

	@SearchableId
	private int id_;
	@SearchableProperty (name = "title")
	private String title_;
	@SearchableProperty (name = "author")
	private String authorName_;
	private Date creationDate_;
	@SearchableProperty (name = "date")
	private String date_;
	@SearchableProperty (name = "body")
	private String body_;
	protected String DELIMITER ="~~~";

	public Post() {
		//does nothing
	}

	public Post(int id, String title, String authorName, Date creationDate,
			String body) {
		id_ = id;
		title_ = title;
		authorName_ = authorName;
		creationDate_ = creationDate;
		body_ = body;
		SimpleDateFormat tDateFormat = new SimpleDateFormat("dd/MM/yyyy");
		date_ = tDateFormat.format(creationDate);
	}



	public String getDate_() {
		return date_;
	}

	public int getId_() {
		return id_;
	}



	public void setId_(int id) {
		id_ = id;
	}



	public String getTitle_() {
		return title_;
	}



	public void setTitle_(String title) {
		title_ = title;
	}



	public String getAuthorName() {
		return authorName_;
	}



	public void setAuthorName(String authorName) {
		authorName_ = authorName;
	}



	public Date getCreationDate_() {
		return creationDate_;
	}



	public void setCreationDate_(Date creationDate) {
		creationDate_ = creationDate;
	}



	public String getBody_() {
		return body_;
	}



	public void setBody_(String body) {
		body_ = body;
	}



	public String getElementAsString(){
		return this.id_+DELIMITER+this.title_+DELIMITER+this.authorName_+DELIMITER+this.date_+DELIMITER+ this.body_;
	}



}
